<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>translate盒子居中效果</title>
    <style>
    div {
        width: 300px;
        height: 200px;
        background-color: orange;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%)     /* 在x和y轴上各减去自身长度的一半 */
    }
    </style>
</head>
<body>
    <div></div>
</body>
</html>